package com.video.tiktokdownloader.nowatermark

import android.app.Application
import android.content.Context
import androidx.room.Room
import com.video.tiktokdownloader.nowatermark.bean.AppDatabase
import com.video.tiktokdownloader.nowatermark.bean.MyDao
import com.zhouyou.http.EasyHttp

/**
 * @author Afra55
 * @date 2020/6/23
 * A smile is the best business card.
 * 没有成绩，连呼吸都是错的。
 * https://github.com/zhou-you/RxEasyHttp
 * 隐私协议：https://668-judan.github.io/Tiktok-video/
 */
class AppApplication : Application() {
    companion object{
        val DEBUG = BuildConfig.DEBUG
        lateinit var context:Context
        private lateinit var db: AppDatabase
        val dao:MyDao by lazy {
            db.dao()
        }

    }
    override fun onCreate() {
        super.onCreate()
        context = this
        EasyHttp.init(this)

        val easyHttpInstance = EasyHttp.getInstance()
        easyHttpInstance.setBaseUrl("https://www.google.com")

        if (DEBUG) {
            easyHttpInstance.debug("MeMeDa", true)
        }
        easyHttpInstance
            .setReadTimeOut(2 * 60 * 1000)
            .setWriteTimeOut(2 * 60 * 100)
            .setConnectTimeout(2 * 60 * 100)
        db =    Room.databaseBuilder(
            this,
            AppDatabase::class.java, "MiMiDa"
        ).allowMainThreadQueries()
            .build()
    }
}